package com.qcby.servlet;

import java.io.IOException;

/************************************
 * @PACKAGE : com.qcby.servlet
 * @Author    :  叫我老伯
 * @Date    : 2022/6/22 22:54
 * @Desc    : 抽象类
 ***********************************/
public abstract class HttpServlet {
    //实现doGet和doPost的抽像方法
    public abstract void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException;
    public abstract void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException;

    //实现service方法,里面是有HttpServletRequest request , HttpServletResponse response两个参数
    public void service(HttpServletRequest request , HttpServletResponse response) throws IOException {
        //如果你的请求方式是 get或者post请求的话，就可以调用响应的方法

        if ("GET".equals(request.getMethod())){
            //如果请求是doGet，就把请求分配到doGet当中去
            doGet(request, response);
        }else if ("POST".equals(request.getMethod())) {
            ////如果请求是doPost，就把请求分配到doPost当中去
            doPost(request, response);
        }
    }
}
